import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/recharge/views/recharge_item.dart';
import 'package:honeypotflutter/modules/recharge/views/recharge_item_header.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/loginInfo/bussine_userInfo.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_switchMonry.dart';
import 'logic.dart';

class RechargePage extends StatefulWidget {
  const RechargePage({Key? key}) : super(key: key);

  @override
  State<RechargePage> createState() => _RechargePageState();
}

class _RechargePageState extends State<RechargePage> {
  final RechargeLogic logic = Get.put(RechargeLogic());

  List<Widget> children = [RechargeItemHeader()];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    List<double> monryList = [10, 50, 100, 300, 500, 1000];
    List<Widget> widgetList = monryList.map((e) => RechargeItem(monry: e)).toList();
    children.addAll(widgetList);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "充值"),
      body: HLScrollView(
        padding: EdgeInsets.all(12),
        children: [
          MGCard(
            backColor: MGColors.themeColor.withOpacity(0.7),
            padding: EdgeInsets.only(top: 35, bottom: 35),
            children: [
              GetBuilder<UserInfoLogic>(
                  init: UserInfoLogic(),
                  builder: (controller) {
                    return MGSwitchMonry(
                      title: "收入余额(元)",
                      showExchange: false,
                      color: MGColors.text1Color,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      monry: controller.userInfo.accountBalance,
                    );
                  }),
            ],
          ),
          MGCard(
            margin: EdgeInsets.only(top: 20),
            children: children,
          )
        ],
      ),
      bottomSheet: Container(
        margin: EdgeInsets.only(bottom: 30),
        child: Text(
          "账户余额，活动充值金额暂不支持提现",
          style: TextStyle(
            fontSize: MGFont.textFont3,
            color: MGColors.text3Color,
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<RechargeLogic>();
    super.dispose();
  }
}
